import { get, post } from '/@/api/request.ts';

enum Api {
    getInputCode = '/sys/randomImage',
    Login = '/sys/login',
    Logout = '/sys/logout',
    GetUserInfo = '/sys/user/getUserInfo',
    auth = '/sys/permission/getPermCode',
    emergencyCenter = '/health-emergency/emergency/center/getCenterDetail',
}

export const getCodeInfo = (params: any) => get(Api.getInputCode + `/${params}`);

export function loginApi(params: any) {
    return post(Api.Login, params);
}

/**
 * @description 获取登录人应急中心数据
 * @param params
 */
export function getEmergencyCenterApi(params?: any) {
    return get(Api.emergencyCenter, params);
}

/**
 * @description: getUserInfo
 */
export function getUserInfo() {
    return get(Api.GetUserInfo, {}).catch((e) => {
        if (e && (e.message.includes('timeout') || e.message.includes('401'))) {
            //接口不通时跳转到登录界面
            // const userStore = useUserStoreWithOut();
            // userStore.setToken('');
            // router.push(PageEnum.BASE_LOGIN);
        }
    });
}

export function getAuth() {
    return get(Api.auth);
}

export function doLogout() {
    return get(Api.Logout);
}
